import { instance } from "@/common/tools/axios";
import { ref } from 'vue';
export default function request<T>(url:string,method:string){

    
    const result = ref< T | null>(null);
    const loading = ref<boolean>(true);

    instance({ url, method })
    .then((res:any)=>{
        loading.value = false;
        result.value = res.data;
    })
    .catch((err:any)=>{
        console.error("请求错误：" + err)
    })

    return {
        result,
        loading
    }
}
